﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.Linq;
namespace QuanLyKhachSan
{
    public partial class frmTinhTrangPhong : DevExpress.XtraEditors.XtraForm
    {
        DataClassesKhachSanDataContext db = new DataClassesKhachSanDataContext(SystemInfo.pub_ConnString);
        public frmTinhTrangPhong()
        {
            InitializeComponent();
        }

        private void frmTinhTrangPhong_Load(object sender, EventArgs e)
        {
            var trangthai = from tt in db.TRANG_THAI_PHONGs select tt;
            gridControlTinhTrang.DataSource = trangthai;
        }


       

        private void gridViewTinhTrang_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
        {
            if (e.Column.FieldName == "")
            {
                if (e.RowHandle >= 0)
                {
                    e.DisplayText = (e.RowHandle + 1).ToString();
                }
            } 
        }

        private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            db.SubmitChanges();
        }

        private void barButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {

            if (gridViewTinhTrang.RowCount == 0)
            {
                XtraMessageBox.Show("Không có dữ liệu để xóa.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                DialogResult result = XtraMessageBox.Show("Bạn có chắc muốn xóa?", "Xác nhận", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk);
                if (result == DialogResult.Yes)
                {

                    gridViewTinhTrang.DeleteSelectedRows();
                    db.SubmitChanges();
                }
            }

        }

        private void btXoa_Click(object sender, EventArgs e)
        {

        }

        
    }
}